package org.estela;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

import org.estela.gui.EstelaFrame;

/**
 * 
 * @author antoniokantek
 *
 */
public class CommandLine {

	/**
	 * 
	 */
	private static void showUsage() {
		
		System.exit(0);
	}
	
	/**
	 * 
	 * @param args
	 * @throws Exception
	 */
	public static void main(final String[] args) throws Exception {
		if (args.length == 0) {
			showUsage();
		}
		
		ArgsParser parser = new ArgsParser();
		parser.addOption("gui", ArgsParser.NO_ARGUMENT, 'g');
		parser.addOption("execute", ArgsParser.REQUIRED_ARGUMENT, 'e');
		parser.addOption("tests", ArgsParser.NO_ARGUMENT, 't');
		
		parser.parse(args);
		
		while (parser.hasMoreOptions()) {
			parser.nextOption();
			switch (parser.getOption()) {
			case 'g':
		//		bootStellaFrame();
				return;
			
			case 'e':
				String programFile = parser.getArgument();
				executeProgram(programFile);
				return;
				
			case 't':
				break;
			}
		}
	}

	/**
	 * 
	 * @param programFile
	 * @throws FileNotFoundException 
	 */
	private static void executeProgram(String programFile) throws FileNotFoundException {
		BufferedReader reader = new BufferedReader(new FileReader(new File(programFile)));
		
	}

	/**
	 * 
	 */
//	private static void bootStellaFrame() {
//		Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
//		Dimension screenDim = toolkit.getScreenSize();
//		int x = screenDim.width / 2;
//		int y = screenDim.height / 2;
//		
//		EstelaFrame frame = new EstelaFrame();
//		frame.setSize(640, 480);
//		frame.setLocation(x - 320, y - 300);
//		frame.setVisible(true);
//	}
}
